package com.cro.prison.task;


import com.cro.prison.utils.DateUtils;
import com.cro.prison.utils.HttpRequestUtil;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

//定时任务模拟摄像头识别到异常并调用接口
@Slf4j
@Component
public class pushErrorTask {
    /**
     * 定时将检测结果推送给websocket
     */
    //@Scheduled(cron = "0/20 * * * * ? ")
    public void pushToAnalyseWeb(){
        /* String s =  HttpTool.sendPost("", "http://127.0.0.1:8081/api/socket/socket/pushToAnalyseWeb/101", "");*/
        HttpRequestUtil.sendPost("http://127.0.0.1:8081/socket/socket/pushToAnalyseWeb/101", "", false);
    }
//    @Scheduled(cron = "0 0/5 * * * ?  ")
    //@Scheduled(cron = "0/20 * * * * * ")
    public void pushToWeb(){
        //HttpRequestUtil.sendPost("http://127.0.0.1:8081/api/socket/socket/push/100","type=1&identity=1&createTime=2022-11-05&description=someone fight&deviceId=1",false);
        Map<String, Object> params = new HashMap<>();
        params.put("type",1);
        params.put("identity",1);
        params.put("createTime", DateUtils.getcustomDateTime(System.currentTimeMillis()));
        params.put("description","someone fight");
        params.put("deviceId",1L);
        params.put("isValid",true);
        params.put("status",0);
        params.put("videoSrc","../../../../static/test.mp4");
        params.put("departId",1L);
        params.put("userId",1L);
        HttpRequestUtil.doPost("http://127.0.0.1:8081/socket/socket/push/100",params);
    }

}
